package com.idbk.chargestation.api;

import com.android.volley.AuthFailureError;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.RetryPolicy;
import com.android.volley.toolbox.StringRequest;
import com.idbk.chargestation.AppContext;
import com.idbk.chargestation.net.EHttpResponse;

import java.util.HashMap;
import java.util.Map;

/**
 * 服务器API
 * 基于Volley网络接口层
 *
 * @author lupc
 */
public class ChargeStationAPI {


    /**
     * 发送请求并在请求中 添加token信息
     *
     * @param URL      url
     * @param params   参数
     * @param response 登录密码
     */
    public static StringRequest postWithToken(
            String URL,
            final Map<String, String> params,
            final EHttpResponse response) {
        AppContext appContext = AppContext.getInstance();
        String token = appContext.getToken();
        if (token != null && token.length() > 1) {
            params.put("token", appContext.getToken());
        }
        return EHttpWrapper.post(URL, params, response);
    }

    /**
     * 登录
     *
     * @param name         登录用户名
     * @param password     登录密码
     * @param pushClientId 个推id
     * @param response     回调
     */
    public static StringRequest login(
            String name,
            String password,
            String pushClientId,
            int userRole,
            EHttpResponse response) {
        final String URL = ChargeStationURL.format("/login.do");
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.username", name);
        params.put("model.password", password);
        params.put("model.userRole", userRole+ "" );
        if (pushClientId != null) {
            params.put("model.cID", pushClientId);
        }
//        params.put("model.agentId", BuildConfig.VENDOR + "");
        return EHttpWrapper.post(URL, params, response);
    }


    /**
     * 用户注册
     *
     * @param username 用户姓名
     * @param password 用户密码
     * @param vcode    验证码
     * @param CID      回调
     * @param response 登录密码
     */
    public static StringRequest register(
            String username,
            String password,
            String vcode,
            String CID,
            EHttpResponse response) {
        final String URL = ChargeStationURL.format("/register.do");
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.username", username);
        params.put("model.password", password);
        params.put("model.vcode", vcode);
        if (CID != null)
            params.put("model.cID", CID);
//        params.put("model.agentId", BuildConfig.VENDOR + "");
        return EHttpWrapper.post(URL, params, response);
    }

    /**
     * 获取注册时候的短信验证码
     *
     * @param mobile   手机号
     * @param flag     标志位，true:注册  false:忘记密码
     * @param response 回调
     */
    public static StringRequest getSimpleSMS(String mobile, boolean flag, EHttpResponse response) {
        final String URL = ChargeStationURL.format("/sms.do");
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.mobile", mobile);
        params.put("model.flag", flag ? "true" : "false");
        return EHttpWrapper.post(URL, params, response);
    }

    /**
     * 获取注册时候的短信验证码
     *
     * @param mobile    手机号
     * @param flag      标志位，true:注册  false:忘记密码
     * @param timestamp 时间戳
     * @param sign      加密值
     */
    public static StringRequest getSimpleSMS(String mobile, boolean flag, String timestamp, String sign, EHttpResponse response) {
        final String URL = ChargeStationURL.format("/sms.do");
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.mobile", mobile);
        params.put("model.flag", flag ? "true" : "false");
        params.put("model.timeStamp", timestamp);
        params.put("model.sign", sign);
//        params.put("model.agentId", BuildConfig.VENDOR + "");
        return EHttpWrapper.post(URL, params, response);
    }
//
    /**
     * @param username        用户名
     * @param newPassword     新密码
     * @param passwordConfirm 确认密码
     * @param checkCode       验证码
     * @param response        回调
     */
    public static StringRequest findPassword(String username, String newPassword,
                                             String passwordConfirm, String checkCode,
                                             EHttpResponse response) {
        final String URL = ChargeStationURL.format("/forget.do");
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.username", username);
        params.put("model.newPassword", newPassword);
        params.put("model.passwordConfirm", passwordConfirm);
        params.put("model.vcode", checkCode);
//        params.put("model.agentId", BuildConfig.VENDOR + "");
        return EHttpWrapper.post(URL, params, response);
    }

    /**
     * 登出
     *
     * @param response response 回调
     */
    public static StringRequest logout(EHttpResponse response) {
        final String URL = ChargeStationURL.format("/user/user!logout.do");
        return EHttpWrapper.get(URL, response);
    }

    /**
     * @param response response 回调
     */
    public static StringRequest getUserInfo(EHttpResponse response) {
        final String URL = ChargeStationURL.format("/user/user.do");
        Map<String, String> params = new HashMap<String, String>();
        AppContext appContext = AppContext.getInstance();
        String token = appContext.getToken();
        if (token != null && token.length() > 1) {
            params.put("token", appContext.getToken());
        }
        return EHttpWrapper.post(URL, params, response);
    }

    /**
     * 重设密码
     *
     * @param response response 回调
     */
    public static StringRequest resetPassword(
            String oldpasswork,
            String password,
            String passwordConfirm,
            String vcode,
            EHttpResponse response) {
        final String URL = ChargeStationURL.format("/user/resetpassword.do");
        Map<String, String> params = new HashMap<String, String>();
        AppContext appContext = AppContext.getInstance();
        String token = appContext.getToken();
        params.put("model.oldPassword", oldpasswork);
        params.put("model.newPassword", password);
        params.put("model.newPasswordConfirm", passwordConfirm);
        params.put("model.vcode", vcode);
        if (token != null && token.length() > 1) {
            params.put("token", appContext.getToken());
        }
        return EHttpWrapper.post(URL, params, response);
    }


    /**
     * 设置用户个人信息
     *
     * @param realName  昵称
     * @param signature 个性签名
     * @param mobile    电话号码
     * @param address   用户地址
     * @param zip       邮政编码
     * @param cardNo    身份证号
     * @param response  回调
     */
    public static StringRequest setUserInfo(
            String realName, String signature, String mobile,
            String address, String zip, String cardNo,
            EHttpResponse response) {
        final String URL = ChargeStationURL.format("/user/user!edit.do");
        Map<String, String> params = new HashMap<String, String>();
        if (realName != null)
            params.put("model.realName", realName);
        if (signature != null)
            params.put("model.signature", signature);
        if (cardNo != null)
            params.put("model.cardNo", cardNo);
        if (mobile != null)
            params.put("model.mobile", mobile);
        if (address != null)
            params.put("model.address", address);
        if (zip != null)
            params.put("model.zip", zip);

        return postWithToken(URL, params, response);
    }

    /**
     * 设置企业子账户绑定手机号
     *
     * @param mobile   用户绑定的手机号
     * @param password 用户密码
     * @param response 回调
     */
    public static StringRequest bindPhone(
            String mobile,
            String password,
            EHttpResponse response){
        final String URL = ChargeStationURL.format("/user/subenterprise!bind.do");
        Map<String, String>params = new HashMap<String, String>();
        if ( mobile != null)
            params.put("model.mobile", mobile);
        if ( password != null)
            params.put("model.password", password);

        return postWithToken(URL, params, response);
    }

    /**
     * 设置企业子账户解除绑定手机号
     *
     * @param  password 用户密码
     */

    public static StringRequest unBindPhone(
            String password,
            EHttpResponse response){
        final String URL = ChargeStationURL.format("/user/subenterprise!unbind.do");
        Map<String,String>params = new HashMap<String, String>();
        if (password != null)
            params.put("model.password",password);

        return postWithToken(URL, params, response);

    }


    /**
     * 查询 我的预约
     *
     * @param response response
     */
    public static StringRequest getMyBespeak(EHttpResponse response) {
        final String URL = ChargeStationURL.format("/charge/bespeak!getList.do");
        AppContext appContext = AppContext.getInstance();
        Map<String, String> params = new HashMap<String, String>();
        params.put("token", appContext.getToken());
        params.put("model.pageIndex", "1");
        params.put("model.pageSize", "10");
        params.put("model.bespeakEnum", "1");
        return EHttpWrapper.post(URL, params, response);
    }


    /**
     * 查询 我的预约历史记录
     *
     * @param mPageIndex 当前页数,从1开始，必须小于等于总页数
     * @param page_size  每页评论数量
     * @param response   回调
     */
    public static StringRequest getBespeakHistory(int mPageIndex, int page_size, EHttpResponse response) {
        final String URL = ChargeStationURL.format("/charge/bespeak!history.do");
        AppContext appContext = AppContext.getInstance();
        Map<String, String> params = new HashMap<String, String>();
        params.put("token", appContext.getToken());
        params.put("model.pageIndex", mPageIndex + "");
        params.put("model.pageSize", page_size + "");
        return EHttpWrapper.post(URL, params, response);
    }


    /**
     * 取消预约
     *
     * @param pileSn   电桩序列号
     * @param response 回调
     */
    public static StringRequest revokePileBespeak(
            String pileSn,
            EHttpResponse response) {
        final String URL = ChargeStationURL.format("/charge/bespeak!revoke.do");
        AppContext appContext = AppContext.getInstance();
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.pileSn", pileSn);
        params.put("token", appContext.getToken());
        return EHttpWrapper.post(URL, params, response);
    }

    /**
     * 获取注册时候的短信验证码
     *
     * @param mobile   手机号
     * @param response 回调
     */
    public static StringRequest getUserBindSMS(String mobile, EHttpResponse response) {
        final String URL = ChargeStationURL.format("/other/sms.do");
        Map<String, String> params = new HashMap<String, String>();
        AppContext appContext = AppContext.getInstance();
        params.put("token", appContext.getToken());
        params.put("model.mobile", mobile);
        return EHttpWrapper.post(URL, params, response);
    }

    /**
     * 获取验证码
     *
     * @param mobile    手机号
     * @param timestamp 时间戳
     * @param sign      加密值
     * @param response  回调
     */
    public static StringRequest getUserBindSMS(String mobile, String timestamp, String sign, EHttpResponse response) {
        final String URL = ChargeStationURL.format("/other/sms.do");
        Map<String, String> params = new HashMap<String, String>();
        AppContext appContext = AppContext.getInstance();
        params.put("token", appContext.getToken());
        params.put("model.mobile", mobile);
        params.put("model.timeStamp", timestamp);
        params.put("model.sign", sign);
        return EHttpWrapper.post(URL, params, response);
    }

    /**
     * 获取Android最新版本信息
     *
     * @param response 回调
     */
    public static StringRequest getVersionInfo(EHttpResponse response) {
        final String url = ChargeStationURL.format("/version!update.do");
        Map<String, String> params = new HashMap<String, String>();
        // android 端更新为 1，ios为 2，这里写死固定为 1
        params.put("model.phoneEnum", "1");
        return EHttpWrapper.post(url, params, response);
    }

    /**
     * 查询 我收藏的 充电点
     *
     * @param pageIndex 当前页数，从1开始，必须小于等于总页数
     * @param pageSize  每页数量
     * @param response  回调
     */
    public static StringRequest getMyPointCollections(
            int pageIndex,
            int pageSize,
            EHttpResponse response) {
        final String URL = ChargeStationURL.format("/user/collection!list.do");
        Map<String, String> params = new HashMap<String, String>();
        AppContext appContext = AppContext.getInstance();
        String token = appContext.getToken();
        if (token != null && token.length() > 1) {
            params.put("token", appContext.getToken());
        }
        params.put("model.pageIndex", pageIndex + "");
        params.put("model.pageSize", pageSize + "");
        return EHttpWrapper.post(URL, params, response);
    }

    /**
     * 我的钱包
     *
     * @param pageIndex   当前页数，从1开始，必须小于等于总页数
     * @param pageSize    每页数量
     * @param mRecordType 记录类型
     * @param response    回调
     */
    public static StringRequest getWalletRecord(int pageIndex, int pageSize, int mRecordType, EHttpResponse response) {
        //final String url = "charge/wallet.do";
        final String URL = ChargeStationURL.format("/charge/wallet!all.do");
        Map<String, String> params = new HashMap<String, String>();
        AppContext appContext = AppContext.getInstance();
        params.put("model.pageIndex", pageIndex + "");
        params.put("model.pageSize", pageSize + "");
        params.put("model.recordType", mRecordType + "");
        if (appContext.isLogin()) {
            params.put("token", appContext.getToken());
        }
        return EHttpWrapper.post(URL, params, response);
    }

    /**
     * 消费记录详情
     *
     * @param tradingLogId 具体消费类型
     * @param detailType   交易类型
     * @param response     回调
     */
    public static StringRequest getConsumptiontRecord(int tradingLogId, int detailType, EHttpResponse response) {
        final String URL = ChargeStationURL.format("/charge/wallet!consume.do");
        AppContext appContext = AppContext.getInstance();
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.tradingLogId", tradingLogId + "");
        params.put("model.detailType", detailType + "");
        if (appContext.isLogin()) {
            params.put("token", appContext.getToken());
        }
        return EHttpWrapper.post(URL, params, response);
    }

    /**
     * 充值记录详情
     *
     * @param tradingLogId 账单Id
     * @param response     回调
     */
    public static StringRequest getRechargeRecord(int tradingLogId, EHttpResponse response) {
        final String URL = ChargeStationURL.format("/charge/wallet!recharge.do");
        AppContext appContext = AppContext.getInstance();
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.tradingLogId", tradingLogId + "");
        params.put("model.tradingType", "2");
        if (appContext.isLogin()) {
            params.put("token", appContext.getToken());
        }
        return EHttpWrapper.post(URL, params, response);
    }


    /**
     * 赠送记录详情
     *
     * @param tradingLogId 账单Id
     * @param response     回调
     */
    public static StringRequest getGiftRecord(int tradingLogId, EHttpResponse response) {
        final String URL = ChargeStationURL.format("/charge/wallet!gift.do");
        AppContext appContext = AppContext.getInstance();
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.tradingLogId", tradingLogId + "");
        params.put("model.tradingType", "3");
        if (appContext.isLogin()) {
            params.put("token", appContext.getToken());
        }
        return EHttpWrapper.post(URL, params, response);
    }


    /**
     * 支付宝充值
     *
     * @param rechargeValue 充值金额
     */
    public static StringRequest payWithAli(double rechargeValue, EHttpResponse response) {
        final String URL = ChargeStationURL.format("/pay/alipay.do");
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.rechargeValue", rechargeValue + "");
        return postWithToken(URL, params, response);
    }

    /**
     * 取消支付
     *
     * @param tradingNo 交易流水号
     */
    public static StringRequest cancelRecharge(int tradingNo,
                                               EHttpResponse response) {
        final String URL = ChargeStationURL.format("/pay/alipay!revoke.do");
        AppContext appContext = AppContext.getInstance();
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.tradingNo", tradingNo + "");
        if (appContext.isLogin()) {
            params.put("token", appContext.getToken());
        }
        return EHttpWrapper.post(URL, params, response);
    }


    /**
     * 微信充值
     *
     * @param rechargeValue 充值金额
     */
    public static StringRequest payWithWeixin(int rechargeValue,
                                              EHttpResponse response) {
        final String URL = ChargeStationURL.format("/pay/micropay.do");
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.rechargeValue", rechargeValue + "");
        return postWithToken(URL, params, response);
    }


    /**
     * 扫码
     *
     * @param pileSn 充电桩序列号
     */
    public static StringRequest qrScan(String pileSn, EHttpResponse response) {
        final String URL = ChargeStationURL.format("/charge/connect.do");
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.pileSn", pileSn);
        return postWithToken(URL, params, response);
    }


    /**
     * 充电点一览
     *
     * @param response 回调
     */
    public static StringRequest getPointsOverview(EHttpResponse response) {
        final String URL = ChargeStationURL.format("/station/overview!points.do");
        Map<String, String> params = new HashMap<String, String>();
        AppContext appContext = AppContext.getInstance();
        String token = appContext.getToken();
        if (token != null && token.length() > 1) {
            params.put("token", appContext.getToken());
        }
//        params.put("model.agentId", BuildConfig.VENDOR + "");
        return EHttpWrapper.post(URL, params, response);
    }

    public static StringRequest getPointDetail(int pointId, EHttpResponse response) {
        final String URL = ChargeStationURL.format("/station/pile!details.do");
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.pointId", pointId + "");
        AppContext appContext = AppContext.getInstance();
        String token = appContext.getToken();
        if (token != null && token.length() > 1) {
            params.put("token", appContext.getToken());
        }
        return EHttpWrapper.post(URL, params, response);
    }

    public static StringRequest collectPoint(int pointId, EHttpResponse response) {
        final String URL = ChargeStationURL.format("/user/collection!collect.do");
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.pointId", pointId + "");
        AppContext appContext = AppContext.getInstance();
        String token = appContext.getToken();
        if (token != null && token.length() > 1) {
            params.put("token", appContext.getToken());
        }
        return EHttpWrapper.post(URL, params, response);
    }

    public static StringRequest cancelCollectPoint(int pointId, EHttpResponse response) {
        final String URL = ChargeStationURL.format("/user/collection!undo.do");
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.pointId", pointId + "");
        AppContext appContext = AppContext.getInstance();
        String token = appContext.getToken();
        if (token != null && token.length() > 1) {
            params.put("token", appContext.getToken());
        }
        return EHttpWrapper.post(URL, params, response);
    }

    public static StringRequest correctPointGeography(
            int pointId,
            double lat,
            double lng,
            String province,
            String city,
            String country,
            String address,
            EHttpResponse response
    ) {
        final String URL = ChargeStationURL.format("/other/correct.do");
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.chargePointId", pointId + "");
        params.put("model.lat", lat + "");
        params.put("model.lng", lng + "");
        params.put("model.provinceName", province);
        params.put("model.cityName", city);
        params.put("model.countryName", country);
        params.put("model.address", address);
        AppContext appContext = AppContext.getInstance();
        String token = appContext.getToken();
        if (token != null && token.length() > 1) {
            params.put("token", appContext.getToken());
        }
        return EHttpWrapper.post(URL, params, response);
    }

    public static StringRequest complain(
            int complaintItem,
            String complaintInfo,
            int pointId,
            EHttpResponse response) {
        final String URL = ChargeStationURL.format("/other/correct!complaint.do");
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.complaintItem", complaintItem + "");
        if (complaintInfo != null) {
            params.put("model.complaintInfo", complaintInfo);
        }
        params.put("model.chargePointId", pointId + "");
        AppContext appContext = AppContext.getInstance();
        String token = appContext.getToken();
        if (token != null && token.length() > 1) {
            params.put("token", appContext.getToken());
        }
        return EHttpWrapper.post(URL, params, response);
    }

    /**
     * 发表评论(充电点)
     *
     * @param pointId  充电点id
     * @param comment  用户评论
     * @param mark     评分(1-5)
     * @param response 回调
     */
    public static StringRequest submitPointComment(
            int pointId,
            String comment,
            int mark,
            EHttpResponse response) {
        final String URL = ChargeStationURL.format("/station/comment!add.do");
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.pointId", pointId + "");
        params.put("model.comment", comment);
        params.put("model.mark", mark + "");
        AppContext appContext = AppContext.getInstance();
        String token = appContext.getToken();
        if (token != null && token.length() > 1) {
            params.put("token", appContext.getToken());
        }
        return EHttpWrapper.post(URL, params, response);
    }

    /**
     * 充电点纠错--联系电话
     *
     * @param pointId    pointId 充电点id
     * @param contactNum 联系电话
     * @param response   回调
     */
    public static StringRequest correctPointContact(
            int pointId,
            String contactNum,
            EHttpResponse response
    ) {
        final String URL = ChargeStationURL.format("/other/correct!phone.do");
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.chargePointId", pointId + "");
        params.put("model.contactNum", contactNum);
        AppContext appContext = AppContext.getInstance();
        String token = appContext.getToken();
        if (token != null && token.length() > 1) {
            params.put("token", appContext.getToken());
        }
        return EHttpWrapper.post(URL, params, response);
    }

    /**
     * 充电点 评论回复
     *
     * @param toClientId           原评论人的id
     * @param comment              评论内容
     * @param chargePointCommentId 原评论的评论id
     * @param isToComent           是否是针对评论的回复
     * @param response             回调
     */
    public static StringRequest replyComment(
            int toClientId,
            String comment,
            int chargePointCommentId,
            boolean isToComent,
            EHttpResponse response
    ) {
        final String URL = ChargeStationURL.format("/station/comment!toReply.do");
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.toClientId", toClientId + "");
        params.put("model.comment", comment);
        params.put("model.chargePointCommentId", chargePointCommentId + "");
        params.put("model.specialFlag", isToComent ? "true" : "false");
        return postWithToken(URL, params, response);
    }

    /**
     * 根据关键字搜索充电点
     *
     * @param keyword  关键字
     * @param response 回调
     */
    public static StringRequest keywordSearch(
            String keyword,
            EHttpResponse response
    ) {
        final String URL = ChargeStationURL.format("/station/search!points.do");
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.keys", keyword);
        AppContext appContext = AppContext.getInstance();
        String token = appContext.getToken();
        if (token != null && token.length() > 1) {
            params.put("token", appContext.getToken());
        }
        return EHttpWrapper.post(URL, params, response);
    }

    /**
     * 预约电桩
     *
     * @param pileSn      电桩序列号
     * @param bespeakTime 预约充电时间 时间段
     * @param gunNum      预约枪口的选择
     * @param response    回调
     */
    public static StringRequest bespeakPile(
            String pileSn,
            int bespeakTime,
            String gunNum,
            final EHttpResponse response
    ) {
        final String URL = ChargeStationURL.format("/charge/bespeak.do");
        final Map<String, String> params = new HashMap<String, String>();
        params.put("model.pileSn", pileSn);
        params.put("model.bespeakTime", bespeakTime + "");
        params.put("model.gunNum", gunNum);
        AppContext appContext = AppContext.getInstance();
        String token = appContext.getToken();
        if (token != null && token.length() > 1) {
            params.put("token", appContext.getToken());
        }

        StringRequest request = new StringRequest(
                com.android.volley.Request.Method.POST,
                URL,
                response.getmListener(),
                response.getmErrorListener()) {

            @Override
            protected void onFinish() {
                super.onFinish();

                response.onEFinish();
            }

            @Override
            protected Map<String, String> getParams()
                    throws AuthFailureError {
                return params;
            }

        };

        int socketTimeout = 20000;//30 seconds - change to what you want
        RetryPolicy policy = new DefaultRetryPolicy(socketTimeout, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
        request.setRetryPolicy(policy);


        AppContext.getInstance().getVolleyQueue().add(request);

        return request;
//		AppContext appContext = AppContext.getInstance();
//		String token = appContext.getToken();
//		if(token != null && token.length() > 1){
//			params.put("token", appContext.getToken());
//		}
//		return EHttpWrapper.post(URL, params, response);
    }

    /**
     * 汽车品牌和型号获取
     *
     * @param response 回调
     */
    public static StringRequest getCarMessage(EHttpResponse response) {
        final String URL = ChargeStationURL.format("/user/vehicleowner!vehicleInfos.do");
        Map<String, String> params = new HashMap<String, String>();
        AppContext appContext = AppContext.getInstance();
        String token = appContext.getToken();
        if (token != null && token.length() > 1) {
            params.put("token", appContext.getToken());
        }
        return EHttpWrapper.post(URL, params, response);
    }

    /**
     * 车主认证信息查询
     *
     * @param response 回调
     */
    public static StringRequest getCertification(EHttpResponse response) {
        final String URL = ChargeStationURL.format("/user/vehicleowner.do");
        Map<String, String> params = new HashMap<String, String>();
        AppContext appContext = AppContext.getInstance();
        String token = appContext.getToken();
        if (token != null && token.length() > 1) {
            params.put("token", appContext.getToken());
        }
        return EHttpWrapper.post(URL, params, response);
    }

    /**
     * 删除车主认证信息
     *
     * @param id       id
     * @param response 回调
     */
    public static StringRequest deleteCertification(int id, EHttpResponse response) {
        final String URL = ChargeStationURL.format("/user/vehicleowner!delete.do");
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.id", id + "");
        AppContext appContext = AppContext.getInstance();
        String token = appContext.getToken();
        if (token != null && token.length() > 1) {
            params.put("token", appContext.getToken());
        }
        return EHttpWrapper.post(URL, params, response);
    }

    /**
     * 充电点采集历史查询
     *
     * @param response 回调
     */
    public static StringRequest getMyUploadPoints(EHttpResponse response) {
        final String URL = ChargeStationURL.format("/other/otherpile!list.do");
        Map<String, String> params = new HashMap<String, String>();
        AppContext appContext = AppContext.getInstance();
        String token = appContext.getToken();
        if (token != null && token.length() > 1) {
            params.put("token", appContext.getToken());
        }
        return EHttpWrapper.post(URL, params, response);
    }

    /**
     * 我要建桩
     *
     * @param name     姓名
     * @param email    邮箱
     * @param phone    手机号
     * @param other    附加说明
     * @param response 回调
     */
    public static StringRequest buildMyPile(
            String name,
            String email,
            String phone,
            String other,
            EHttpResponse response
    ) {
        final String URL = ChargeStationURL.format("/other/buildpile.do");
        Map<String, String> params = new HashMap<String, String>();

        params.put("model.customerName", name);
        params.put("model.Email", email);
        params.put("model.phoneNum", phone);
        params.put("model.remark", other);

        AppContext appContext = AppContext.getInstance();
        String token = appContext.getToken();
        if (token != null && token.length() > 1) {
            params.put("token", appContext.getToken());
        }
        return EHttpWrapper.post(URL, params, response);
    }

    /**
     * 获取 我的评论
     *
     * @param pageIndex 当前页数，从1开始，必须小于等于总页数
     * @param pageSize  每页评论数量
     * @param response  回调
     */
    public static StringRequest getMyPointComments(
            int pageIndex,
            int pageSize,
            EHttpResponse response
    ) {
        final String URL = ChargeStationURL.format("/station/comment!own.do");
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.pageIndex", pageIndex + "");
        params.put("model.pageSize", pageSize + "");

        return postWithToken(URL, params, response);
    }

    /**
     * 删除 单条我的评论
     *
     * @param chargePointCommentId 删除的评论id
     * @param response             回调
     */
    public static StringRequest deleteComment(
            int chargePointCommentId,
            EHttpResponse response
    ) {
        final String URL = ChargeStationURL.format("/station/comment!delete.do");
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.chargePointCommentId", chargePointCommentId + "");

        return postWithToken(URL, params, response);
    }

    /**
     * 获取 欢迎页面广告信息
     *
     * @param id       id
     * @param response 回调
     */
    public static StringRequest getWelcomeADsInfo(int id, EHttpResponse response) {
        final String URL = ChargeStationURL.format("/homepageadv.do");
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.id", id + "");
        return EHttpWrapper.post(URL, params, response);
    }

}
